<!--
  Copyright 2017 Huawei Technologies Co., Ltd.
 
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
 
      http://www.apache.org/licenses/LICENSE-2.0
 
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<md-dialog aria-label="Upload Service dialog" flex="40" id="uploadDialog">

    <md-toolbar class="md-hue-3 dialogHeader">
        <div class="md-toolbar-tools" id="uploadStyle">
            <h2  ng-if="vm.isUpload" >{{'module.marketplace.serviceUpload.title' | translate}}</h2>
			<h2  ng-if="!vm.isUpload" >{{'module.marketplace.serviceUpload.updateTitle' | translate}}</h2>
            <span flex></span>
            <button class="btnTransparency" ng-click="vm.cancel()" ng-hide="vm.status == 'progress'">
                    <i class="fa fa-close fa-sm" aria-hidden="true"></i>
            </button>
        </div>
    </md-toolbar>
    <form ng-cloak name="service">
        <md-dialog-content ng-show="vm.status == 'Idle'">
            <span class="UploadPageIndicator"> </span>
            <div class="md-dialog-content">
                <div layout="column">
                    <label>{{'module.marketplace.serviceUpload.fields.fileUpload.label' | translate}}</label>
                    <div class="">
                        <label for="file" class="btn btnDefault"> {{'common.actions.add' | translate}} </label>
                        <label>
                            <span ng-if="!vm.service.file"> {{'module.marketplace.serviceUpload.fields.fileUpload.noFileSelected' | translate}}</span>
                            <span ng-if="vm.service.file">  {{ vm.service.file.name}}</span>
                        </label>
                    </div>
                    <input class="hidden" id="file" type="file" file-upload="vm.service.file" md-asterisk accept=".csar">

                </div>

                <div>
                        <label for="shortDesc" class="labels">{{'module.marketplace.serviceUpload.fields.shortDescription.placeholder' | translate}}</label>
                        <input ng-model="vm.service.shortDesc" type="text" id="shortDesc" name="shortDesc">
                </div>
                <div>
                    
                        <label class="labels">{{'module.marketplace.serviceUpload.fields.details.placeholder' | translate}}</label>
                        <textarea name="details" ng-model="vm.service.details" maxlength="150" rows="3" md-select-on-focus></textarea>
                </div>
                <div>
                   
                        <label for="remarks" class="labels">{{'module.marketplace.serviceUpload.fields.remarks.placeholder' | translate}}</label>
                        <input ng-model="vm.service.remarks" type="text" id="remarks" name="remarks">
                </div>
            </div>
        </md-dialog-content>

    </form>

    <md-dialog-content ng-show="(vm.status == 'progress') || (vm.status == 'success')">
        <div class="md-dialog-content" layout="column" layout-sm="column">
            <div flex layout="row">
                <div flex="25" layout="column">
                </div>
                <div flex="50" layout="column">
                    <h4 class="text-center" ng-if="vm.status != 'success'"> {{'module.marketplace.serviceUpload.messages.onUploading' | translate}} </h4>
                    <div class="fullWidth center" ng-if="vm.status == 'success'">
                        <div class="row">
                            <div class="col-xs-2 col-sm-2 col-md-1 col-lg-1 deleteIconSize glyphicon glyphicon-info-sign icon_info con_confirm"></div>
                            <h4 class="msg col-xs-10 col-sm-10 col-md-10 col-lg-10" style="text-align:left;vertical-align: middle;">{{'module.marketplace.serviceUpload.messages.onSuccessful' | translate}}</h4>
                        </div>
                    </div>
                    <md-progress-linear md-mode="determinate" value="{{vm.apiInfo}}"></md-progress-linear>
                    <h4 class="text-center"> {{vm.apiInfo}} % </h4>
                    <span class="text-center" ng-if="vm.status == 'success'">{{'module.marketplace.serviceUpload.fields.funcTestReport.label' | translate}} <a href="{{vm.funcTestReportUrl}}" target="_blank">{{'common.actions.clickHere' | translate}}</a></span>
                </div>
                <div flex="25" layout="column">
                </div>
            </div>
        </div>
    </md-dialog-content>



    <md-dialog-actions layout="row" ng-show="vm.status == 'Idle'" class="marginAuto">
        <!-- <span flex></span> -->
        
		<button ng-if="!vm.isUpload" class="md-raised btn btnPrimary btnPrimaryPadding btnSpacing" ng-click="vm.answer('Uploaded')" ng-disabled="!vm.service.file">
            {{'common.actions.update' | translate}}
        </button>
		
        <button ng-if="vm.isUpload" class="md-raised btn btnPrimary btnPrimaryPadding btnSpacing" ng-click="vm.answer('Uploaded')" ng-disabled="!vm.service.file">
            {{'common.actions.upload' | translate}}
        </button>

        <button class="md-raised btn btnDefault btnPrimaryPadding btnSpacing" ng-click="vm.cancel()">
            {{'common.actions.close' | translate}}
        </button>
       

    </md-dialog-actions>
    <md-dialog-actions class="marginAuto" layout="row" ng-show="vm.status == 'success'">
        <button class="btn btnDefault" ng-click="vm.hide('Uploaded')">
            {{'common.actions.ok' | translate}}
        </button>
    </md-dialog-actions>
</md-dialog>